<?php if(!IS_AJAX){ ?> 
<include file="Public:header" /> <include file="Public:navgation" />
<link rel="stylesheet" type="text/css" href="/Public/Js/zTree_v3/css/zTreeStyle/zTreeStyle.css">
<link rel="stylesheet" type="text/css" href="/Public/Intesys/default/stylesheets/jquery.gantt.css">
<div class="container-fluid main-content"> 
  <div class="page-title chart-container"> </div>
  <div class="row">
  	<div class="col-md-3 col-sm-4 hidden-xs">
    	<div class="widget-container">
          <div class="heading">
          	  <form role="form" method="post" action="{:U('index')}" class="checkoutform">
                  <div class="form-group opacity">
                      <div class="panel">
                          <div class="panel-heading">
                              <div class="panel-title">
                                  <a class="accordion-toggle collapsed" data-parent="#accordion" data-toggle="collapse" href="#faq1" style="font-size:14px">
                                      <div class="caret pull-right"></div>
                                      任务状态
                                  </a>
                              </div>
                          </div>
                          <div class="panel-collapse collapse" id="faq1">
                              <div class="panel-body" style="font-size: 14px;">
                                  <label class="radio" style=" margin-bottom:5px; margin-right:15px;"><input value="" name="status" type="radio" nullmsg="" datatype="*" errormsg="" checked="checked"><span>全部</span></label>
                                  <label class="radio" style=" margin-bottom:5px; margin-right:15px;"><input value="0" name="status" type="radio" nullmsg="" datatype="*" errormsg="" <eq name="status" value="0">checked="checked"</eq>><span>驳回</span></label>
                                  <label class="radio" style=" margin-bottom:5px; margin-right:15px;"><input value="2" name="status" type="radio" nullmsg="" datatype="*" errormsg="" <eq name="status" value="2">checked="checked"</eq>><span>进行中</span></label>
                                  <label class="radio" style=" margin-bottom:5px; margin-right:15px;"><input value="3" name="status" type="radio" nullmsg="" datatype="*" errormsg="" <eq name="status" value="3">checked="checked"</eq>><span>待审核</span></label>
                                  <label class="radio" style=" margin-bottom:5px; margin-right:15px;"><input value="4" name="status" type="radio" nullmsg="" datatype="*" errormsg="" <eq name="status" value="3">checked="checked"</eq>><span>待评分</span></label>
                                  <label class="radio" style=" margin-bottom:5px; margin-right:15px;"><input value="5" name="status" type="radio" nullmsg="" datatype="*" errormsg="" <eq name="status" value="3">checked="checked"</eq>><span>已通过</span></label>
                              </div>
                          </div>
                      </div>
                  </div>
                  <hr>
                  <div class="form-group">
                      <label for="email">搜索关键词</label>
                      <input class="form-control" id="keywords" name="keywords" value="{$keywords}" placeholder="任务名称" type="text">
                  </div>
                  <hr>
                  <div class="form-group">
                      <div class="row">
                          <div class="col-sm-12 col-xs-12" style="margin:0;padding:0"><input class="form-control" id="starttime" name="starttime" readonly onClick="WdatePicker();" style="cursor:pointer;" value="{$starttime}" placeholder="起始时间" type="text"></div>
                      </div>
                      <div class="row">
                          <div class="col-sm-12 col-xs-12" style="margin:0;padding:0"><input class="form-control" id="endtime" name="endtime" onClick="WdatePicker();" readonly style="cursor:pointer;" value="{$endtime}" placeholder="结束时间" type="text"></div>
                      </div>
                  </div>
                  <hr>
                  <div class="form-group">
                      <div class="col-md-12"  style="margin:0;padding:0">
                          <select class="form-control" name="pagesize" style="display:inline;width:50%;margin-right:15px;">
                              <option value="10" <eq name="pagesize" value="10">selected="selected"</eq>>每页10条</option>
                              <option value="25" <eq name="pagesize" value="25">selected="selected"</eq>>每页25条</option>
                              <option value="50" <eq name="pagesize" value="50">selected="selected"</eq>>每页50条</option>
                              <option value="100" <eq name="pagesize" value="100">selected="selected"</eq>>每页100条</option>
                          </select>
                          <button class="btn btn-sm btn-info pull-right" style="margin:0;padding:5px 15px;border-radius:0">点击搜索</button>
                      </div>
                  </div>
              </form>
          </div>
        </div>
    </div>
    <div class="col-md-9 col-sm-8 col-xs-12">
      <div class="widget-container">
            <div class="heading"> 
                <i class="icon-bar-chart"></i>任务管理
                <if condition="getAccessMenu($accessList, 'Intesys', 'Task', 'insert')&&!isMobile()"> 
                	<a class="pull-right" onClick="_openWindow('{:U('add')}',500, '创建任务', '提交',null,'')" href="#">添加</a> 
                </if>
            </div> 
			<style>
				.form-box{overflow: hidden;width: 100%;padding: 10px;border: #ddd solid 1px;background: white;margin: 10px 0;}
				 small.label{ line-height:1.4 !important;}
				.ztree .title{ width:100%; float:left; font-size:16px; font-weight:bold;}
				.ztree li a:hover{ text-decoration:none;}
				.ztree li a > span{ padding-right:10px; display:inline-block; box-sizing:border-box; overflow:hidden; margin-right:0; width:50%; padding:4px 0; float:left;}
				.ztree li a > span:last-child{ width:100%;}
				.ztree li span.roots_close,.ztree li span.roots_open,.ztree li span.center_open,.ztree li span.center_close,.ztree li span.bottom_close,.ztree li span.bottom_open{ background:none; color:#007aff; cursor:pointer;}
				.ztree li { padding:15px 15px;background: #fff;}
				.ztree > li{margin: 4px 0;box-shadow: 0px 1px 4px rgba(0,0,0,0.14); transition:all ease-in-out 0.2s;}
				.ztree > li:hover{box-shadow:none;}
				.ztree li > a{ min-width:97%; margin-bottom:15px; box-sizing:border-box; border:1px solid #fff; width:99%; position:relative;}
				.BottomOptionBtn{position: absolute;bottom: 0;width: 50%;right: 0;top: 10px;}
				@media(max-width:760px){
					.hidden-760{ display:none !important;}
					.ztree li > span,.ztree li a{ width:10%; }
					.ztree li a > span{ width:100%;}
					.ztree li{ margin:4px 0;}
				}
			</style> 
        <div class="widget-content DataList">
            
            <?php } ?>  
            <script type="text/javascript">
			<!--
			function transStatu(statu){
				switch (statu){
					case '0':
						return '失败';
					case '1':
						return '未进行中';
					case '2':
						return '进行中';
					case '3':
						return '待审核';
					case '4':
						return '待评价';
					case '5':
						return '完成';
				}	
			}
			//在树状图的文字中添加任务的更多信息
			function addDiyDom(treeId, treeNode) {
				console.log(treeNode);
				var member_id='{:session(C('USER_AUTH_KEY'))}';
				var aObj = $("#" + treeNode.tId + "_a");
				$("#" + treeNode.tId + "_span").addClass("title");
				var editStr = "<span class='text-normal'>状态："+transStatu(treeNode.status)+"</span><span class='text-normal'>参与者："
					+treeNode.member_name+"</span><span class='text-normal'>开始时间："
					+format(treeNode.starttime)+"</span><span class='text-normal'>审核者："
					+treeNode.reviewer_name+"</span><span class='text-muted pull-left'>备注："
					+treeNode.remark+"</span><div id='diyBtn_"+treeNode.tId+"' class='BottomOptionBtn <?= isMobile()?'hidden':'' ?>'>"
					+"<a class='diyBtn button text-primary'  onClick='_openWindow(\"__URL__/view/id/"
					+treeNode.id+"\",500, \"查看任务\", \"取消\",null,\"\")'  onfocus='this.blur();'><i class=\"icon-eye-open\"></i>查看</a>"
					+"<a class='diyBtn button text-primary'  onClick='_openWindow(\"__URL__/viewProgress/id/"
					+treeNode.id+"\",800, \"查看进度\", \"提交\",null,\"\")'  onfocus='this.blur();'><i class=\"icon-list-ul\"></i>进度</a>";
				//进行中	
				if((treeNode.member_id==member_id||treeNode.creator_id==member_id)&&(treeNode.status==2||treeNode.status==1)){
					editStr+="<a class='diyBtn button text-primary'  onClick='_openWindow(\"__URL__/add/id/"
							+treeNode.id+"\",500, \"新建下级任务\", \"提交\",null,\"\")'  onfocus='this.blur();'><i class=\"icon-plus\"></i>增加</a>"
							+"<a class='diyBtn  button text-primary'  onClick='_openWindow(\"__URL__/outTask/id/"
							+treeNode.id+"\",500, \"分发任务\", \"提交\",null,\"\")'  onfocus='this.blur();'><i class=\"icon-sort-by-attributes\"></i>分发</a>"
							+"<a class='diyBtn button text-primary'  onClick='_openWindow(\"__URL__/newProgress/id/"
							+treeNode.id+"\",500, \"更新进度\", \"提交\",null,\"\")'  onfocus='this.blur();'><i class=\"icon-indent-left\"></i>更新</a>"
							+"<a class='diyBtn button text-success' onClick='_openWindow(\"__URL__/edit/id/"
							+treeNode.id+"\",500, \"修改任务\", \"提交\",null,\"\")'  onfocus='this.blur();'><i class=\"icon-pencil\"></i>修改</a>"
							+"<a class='diyBtn button text-danger' onClick='getReload(\"__URL__/delete/id/"
							+treeNode.id+"\")'  onfocus='this.blur();'><i class=\"icon-trash\"></i>删除</a>";
				}
				//待审核
				if(treeNode.reviewer_id==member_id&&treeNode.status==3){
					editStr+="<a class='diyBtn button text-success' onClick='getReload(\"__URL__/pass/id/"
					+treeNode.id+"\")'  onfocus='this.blur();'><i class=\"icon-check\"></i>通过</a>"
					+"<a class='diyBtn button text-danger' onClick='getReload(\"__URL__/fail/id/"
					+treeNode.id+"\")'  onfocus='this.blur();'><i class=\"icon-check\"></i>驳回</a>";
				}
				//待评分
				if(treeNode.member_id==member_id&&treeNode.status==4){
					editStr+="<a class='diyBtn button text-primary'  onClick='_openWindow(\"__URL__/score/id/"
					+treeNode.id+"\",500, \"任务评分\", \"提交\",null,\"\")'  onfocus='this.blur();'><i class=\"icon-gittip\"></i>评分</a>";
				}
				editStr+="</div>";
				$(".ico_close").remove();
				$(".ico_docu").remove();
				aObj.append(editStr);
			};
			//当鼠标移动到节点上的时候
			function addHoverDom(treeId,treeNode){
				if(!treeNode){return;}
				<?php if(!isMobile()){ ?>
					$("#diyBtn_"+treeNode.tId).removeClass('hidden');
				<?php } ?>
				
				$(".ico_close").remove();
			}
			function removeHoverDom(treeId,treeNode){
				//$("#diyBtn_"+treeNode.tId).addClass('hidden');
			}
			function refreshNode(e) {
				var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
				type = e.data.type,
				silent = e.data.silent,
				nodes = zTree.getSelectedNodes();
				if (nodes.length == 0) {
					alert("没有下级了");
				}
				for (var i=0, l=nodes.length; i<l; i++) {
					zTree.reAsyncChildNodes(nodes[i], type, silent);
					if (!silent) zTree.selectNode(nodes[i]);
				}
			}
			//点击显示当前目录的下级
			function onclick(event, treeId, treeNode){
				if(treeNode){
					$("#"+treeNode.tId+"_switch").click();
				}
			}
			var setting = { 
				view: {
					selectedMulti: false,
					addDiyDom: addDiyDom,
					addHoverDom: addHoverDom,
					removeHoverDom: removeHoverDom
				},
				callback:{
					onClick:onclick	
				},
				data:{
					key:{
						name:"title"	
					}
				},
				<?php $arr=[]; foreach($_REQUEST as $k=>$v){
					//循环遍历传过来的参数
					if(is_array($v)){continue;}
					$arr[$k]=$v;
				} ?>
				async: {
					enable: true,
					url:"{:U('getTask',$arr)}"
				}
			};
			$(document).ready(function(){
				$.fn.zTree.init($("#treeDemo"), setting);
				$("#refreshNode").bind("click", {type:"refresh", silent:false}, refreshNode);
				$("#refreshNodeSilent").bind("click", {type:"refresh", silent:true}, refreshNode);
				$("#addNode").bind("click", {type:"add", silent:false}, refreshNode);
				$("#addNodeSilent").bind("click", {type:"add", silent:true}, refreshNode);
			});
			//-->
			</script>	
            <div id="treeDemo" class="ztree DataListItem"></div>
            
<?php if(!IS_AJAX){ ?>         
        </div>

      </div>
    </div>
  </div>
</div>
<script>
//异步提交链接并更新主内容
function getReload(url){
	$.getJSON(url,{},function(data){if(data.status==0){alert(data.info);};var treeObj=$.fn.zTree.getZTreeObj("treeDemo");treeObj.reAsyncChildNodes(null, "refresh");})
}
//显示 选择公司员工 的窗口
function showMemberRadioView(classname){
	var classname=classname||'executor_id';
	_openWindow('{:U('Member/getMemberGroupRadio')}',500, '选择员工', '确定',function(){setInputValue(classname);},'');
}

</script> 
<script type="text/javascript" src="/Public/Js/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="/Public/Js/zTree_v3/js/jquery.ztree.exedit.js"></script>
<script type="text/javascript" src="/Public/Intesys/default/javascripts/jquery.fn.gantt.js"></script>
<include file="Public:footer" />
<?php } ?>